<!--
 * @Author: hucc
 * @Date: 2021-10-09 14:34:07
 * @LastEditors: hucc
 * @LastEditTime: 2021-10-10 17:58:41
 * @Description: 
-->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../js/vue.js"></script>
    <style>
        .outer {
            width: 500px;
            height: 300px;
            background-color: darkorange;
            overflow: scroll;
        }
        
        .inner {
            width: 200px;
            height: 1000px;
            background-color: mediumspringgreen;
            margin: 100px;
        }
    </style>
</head>

<body>
    <div id="app">
        <input type="text" @keyup.enter="enterHandler" @mousedown.left="leftMousedownHandler">
        <!-- @click.prevent 阻止事件默认行为  -->
        <!-- @click.prevent.once 阻止默认行为一次 -->
        <a href="https://www.baidu.com" @click.prevent.once="toBaiDuHandler">百度一下</a>
        <!-- @click.self 冒泡依然存在  -->
        <!--@click.capture 由外而内捕获执行 不是冒泡执行  -->
        <div class="outer" @click.capture='outerClickHandler' @scroll.passive='scrollHandler'>
            outer
            <!-- @click.stop vue阻止事件冒泡 -->
            <div class="inner" @click.capture='innerClickHandler'>inner</div>
        </div>

    </div>
    <script>
        let vm = new Vue({
            el: '#app',
            data: {

            },
            methods: {
                outerClickHandler(e) {
                    console.log('outer', e.target, e.currentTarget);
                },
                //点击inner冒泡 输出inner outer
                innerClickHandler(e) {
                    //e.target 触发当前事件的源，谁触发的就是谁
                    //e.currentTarget 执行当前事件的源，绑定在谁身上就是谁
                    console.log('inner', e.target, e.currentTarget);
                    //阻止inner冒泡
                    //e.stopPropagation();
                },
                toBaiDuHandler() {
                    console.log('百度一下');
                },
                scrollHandler() {
                    console.log('滚动一下');
                    let result = 0;
                    for (let i = 0; i < 100000000; i++) {
                        result += i
                    }
                    console.log(result);
                },
                enterHandler(e) {
                    console.log(e.target.value);
                },
                leftMousedownHandler() {
                    console.log('鼠标左边按下');
                }
            },
            created() {}
        })
    </script>
</body>

</html>